<template>
	<view class="order">
		<uni-nav-bar left-icon="arrowleft" right-icon="search" title="需上交金额报表" @clickLeft="back" @clickRight="find" :fixed="true" class="top" status-bar></uni-nav-bar>
		<view class="statistics">
			<view class="ul">
				<view class="li">
					<view>{{detail.needUppay||'0.00'}}</view>
					需上交总额
				</view>
				<view class="li">
					<view>{{detail.hasUpPay||'0.00'}}</view>
					已上交总额
				</view>
			</view>
		</view>
		<view class="table">
			<view class="th">
				<view class="tr">订单号</view>
				<view class="tr">需收金额</view>
				<view class="tr">上缴人</view>
				<view class="tr">上缴金额</view>
				<view class="tr">收款人</view>
			</view>
			<view class="td" v-for="(item,index) in list">
				<view class="tb">{{item.orderSn}}</view>
				<view class="tb">{{item.needReceive}}</view>
				<view class="tb">{{item.payer}}</view>
				<view class="tb">{{item.needUppay}}</view>
				<view class="tb">{{item.receivor}}</view>
			</view>
		</view>
		<view class="total">合计：上交金额：{{detail.needUppay||'0.00'}} 本页共需上交金额200元</view>
		<view class="pagination">
			<view class="left" :class="{ forbid: paging.page == 1 }" @click="prev">
				<uni-icons type="arrowleft" size="20" color="#fff" class="icons" />
				上一页
			</view>
			<view class="center">{{ paging.page }}/{{ paging.total }}</view>
			<view class="right" :class="{ forbid: paging.page == paging.total }" @click="next">
				下一页
				<uni-icons type="arrowright" size="20" color="#fff" class="icons" />
			</view>
		</view>
		<view class="go-top" v-show="is_go_top" @click="backTop"><image src="/static/img/go_top.png" /></view>
	</view>
</template>

<script>
import { uniNavBar, uniIcons } from '@dcloudio/uni-ui';
import handed from '../../../servers/agent/statement/handed.js';
export default {
	components: { uniNavBar, uniIcons },
	data() {
		return {
			active: 0,
			dataList: [1],
			paging: {
				page: 1,
				total: 100
			},
			is_go_top: false,
			detail:[],
			list:[],
			money:0
		};
	},
	onPageScroll: function(e) {
		//nvue暂不支持滚动监听，可用bindingx代替
		if (e.scrollTop > 200) {
			this.is_go_top = true;
		} else {
			this.is_go_top = false;
		}
	},
	mounted() {
		this.getupPay()
		this.getstatistics()
	},
	methods: {
		getupPay(){
			handed.statistics().then(res => {
				this.detail=res.data
			})
		},
		getstatistics(){
			var da = {
				currentPage: this.paging.page,
				pageSize: 10
			}
			handed.upPay(da).then(res => {
				this.list = res.data.records.map(v=>{
					this.money+= v.needUppay
					return v
				})
				this.paging.total = res.data.pages||1
				// this.paging.page = res.data.pages||1
			})
		},
		back() {
			uni.navigateBack({
				delta: 1
			});
		},
		cut(e) {
			this.active = e;
		},
		find() {
			uni.navigateTo({
				url: '../order/orderfind'
			});
		},
		next() {
			if (this.paging.page < this.paging.total) {
				this.paging.page += 1;
				this.getstatistics()
			}
		},
		prev() {
			if (this.paging.page > 1) {
				this.paging.page -= 1;
				this.getstatistics()
			}
		},
		// 计算距离顶部的高度，均分10等分，
		backTop() {
			uni.pageScrollTo({
				scrollTop: 0,
				duration: 200
			});
		}
	}
};
</script>

<style lang="less" scoped>
page {
	background: #ffffff;
}
.order {
	.statistics {
		margin: 37rpx 20rpx 0;
		background: #ffffff;
		border-radius: 10rpx;
		box-shadow: 5rpx 0px 20rpx #c5c5c5;
		.ul {
			padding: 30rpx 0;
			line-height: 60rpx;
			display: flex;
			flex-direction: row;
			text-align: center;
			font-size: 26rpx;
			border-bottom: 1px solid #e1e1e1;
			.li {
				width: 50%;
				font-size: 26rpx;
				view {
					font-size: 40rpx;
					font-weight: 900;
					color: #f70225;
				}
			}
			.li:nth-child(1) {
				border-right: 1px solid #e1e1e1;
			}
		}
	}
	.table {
		margin: 50rpx 20rpx 20rpx;
		border: 1px solid #e1e1e1;
		border-bottom: none;
		background: #ffffff;
		.th,
		.td {
			display: flex;
			flex-direction: row;
			line-height: 94rpx;
			border-bottom: 1px solid #e1e1e1;
			.tr,
			.tb {
				width: 20%;
				text-align: center;
				font-size: 26rpx;
				padding: 0 10rpx;
				border-left: 1px solid #e1e1e1;
				box-sizing: border-box;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			.tr:nth-child(1),
			.tb:nth-child(1) {
				border-left: none;
			}
		}
		.th {
			background: #f4f4f4;
		}
	}
	.total {
		text-align: center;
		color: #f70225;
		font-size: 30rpx;
		line-height: 140rpx;
	}
}
</style>
